package org.mics.cyy.backUser.controller;

import javax.annotation.Resource;

import org.mics.core.response.SimpleResponse;
import org.mics.cyy.backUser.request.RoleMenuRequest;
import org.mics.cyy.backUser.service.RoleMenuService;
import org.mics.lang.exception.CustomException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 角色菜单
 * @author mics
 * @date 2023-10-9
 * @version  1.0
 */
@RestController
@RequestMapping("/roleMenu")
@Tag(name = "角色菜单关系")
public class RoleMenuContorller {
	@Resource
	private RoleMenuService roleMenuService;
	
	@Operation(summary =  "给角色分配菜单")
    @RequestMapping(value = "/grant",method = RequestMethod.POST)
	public SimpleResponse grant(@Validated @RequestBody RoleMenuRequest roleMenuRequest ) {
		if(roleMenuRequest.getMenuIds() == null || roleMenuRequest.getMenuIds().length ==0) {
			throw new CustomException("分配的菜单不能为空");
		}
		roleMenuService.grant(roleMenuRequest);
		return new SimpleResponse();
	}
	

	
}
